home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.src.lzh / relay / hdrdefs.c < prev    next >
C/C++ Source or Header  |  1989-07-08  |  5KB  |  148 lines

  1. #ifdef AMIGA                /* Some type of Amiga */
  2. #  ifndef MCH_AMIGA            /* Not Manx 3.6a, but ... */
  3. #    define LATTICE_4_0        /* Because of all the compiler bugs!! */
  4. #    define CONST
  5. #  else
  6. #    define LATTICE_4_0        /* Because of all the compiler bugs!! */
  7. /* temporary */
  8. #    define CONST    /* const */
  9. #  endif
  10. #endif
  11.  
  12. /*
  13.  * Usenet header definitions (see ARPA Internet RFCs 1036 nee 850 & 822;
  14.  *    for a second opinion, see The Hideous Name by Pike & Weinberger).
  15.  *
  16.  * Headers are parsed and modified and copied in one pass.
  17.  * Nevertheless, the code is in pieces: hdrdefs.c, hdrcommon.c,
  18.  * hdrparse.c, hdrmunge.c.
  19.  */
  20.  
  21. #include <stdio.h>
  22. #ifndef AMIGA
  23. #  include <sys/types.h>
  24. #endif /* AMIGA */
  25. #ifdef REALSTDC
  26. #  include <stdlib.h>
  27. #endif                /* REALSTDC */
  28.  
  29. #include "news.h"
  30. #include "headers.h"
  31. #include "hdrint.h"        /* may define "CONST" */
  32.  
  33. #ifndef offsetof
  34. #define offsetof(type, mem) ((char *)&((type *)NULL)->mem - (char *)NULL)
  35. #endif
  36.  
  37. /* "mandatory" headers (also From:, Date:) */
  38. static CONST char msgnm[] =    "Message-ID:";    /* for rejection */
  39. static CONST char ngsnm[] =    "Newsgroups:";    /* filing, clone for Xref */
  40. static CONST char pathnm[] = "Path:";        /* rejection, extend (damn) */
  41. static CONST char subjnm[] = "Subject:";    /* for ctl. msgs. */
  42.  
  43. /* optional headers */
  44. static CONST char appnm[] =    "Approved:";    /* for mod. groups */
  45. static CONST char ctlnm[] =    "Control:";        /* ctl. msg. */
  46. static CONST char expnm[] =    "Expires:";        /* for history */
  47. static CONST char distrnm[] = "Distribution:";    /* for transmission */
  48. static CONST char sendnm[] = "Sender:";        /* for mod. groups */
  49. static CONST char xrefnm[] = "Xref:";        /* to *replace* (damn!)*/
  50.  
  51. /* obsolete "useful" headers */
  52. static CONST char artnm[] =    "Article-I.D.:";    /* obs. Message-ID: */
  53.  
  54. /* obsolete useless headers: delete them all on contact */
  55. static CONST char datercvnm[] =    "Date-Received:";
  56. static CONST char rcvnm[] =        "Received:";    /* obsolete Date-Received: */
  57. static CONST char postnm[] =    "Posted:";        /* obsolete Date: */
  58. static CONST char postversnm[] = "Posting-Version:";
  59. static CONST char rlyversnm[] =    "Relay-Version:";
  60. static CONST char illobjnm[] =    "Illegal-Object:";    /* zmailer bitching */
  61.  
  62. #ifdef LATTICE_4_0
  63. static CONST struct hdrdef msghdr = { msgnm, STRLEN(msgnm), 20 };
  64. static CONST struct hdrdef ngshdr = { ngsnm, STRLEN(ngsnm), 4 };
  65. CONST struct hdrdef pathhdr = { pathnm, STRLEN(pathnm), 32 };
  66. static CONST struct hdrdef subjhdr = { subjnm, STRLEN(subjnm), 0 };
  67.  
  68. static CONST struct hdrdef apphdr = { appnm, STRLEN(appnm), 16 };
  69. static CONST struct hdrdef ctlhdr = { ctlnm, STRLEN(ctlnm), 12 };
  70. static CONST struct hdrdef exphdr = { expnm, STRLEN(expnm), 28 };
  71. static CONST struct hdrdef distrhdr = { distrnm, STRLEN(distrnm), 8 };
  72. static CONST struct hdrdef sendhdr = { sendnm, STRLEN(sendnm), 24 };
  73. CONST struct hdrdef xrefhdr = { xrefnm, STRLEN(xrefnm), -1 };
  74.  
  75. static CONST struct hdrdef arthdr = { artnm, STRLEN(artnm), 24 };
  76.  
  77. #else    /************************************************************/
  78.  
  79. static CONST struct hdrdef msghdr = {
  80.     msgnm, STRLEN(msgnm), offsetof(struct headers, h_msgid) };
  81. static CONST struct hdrdef ngshdr = {
  82.     ngsnm, STRLEN(ngsnm), offsetof(struct headers, h_ngs) };
  83. CONST struct hdrdef pathhdr = {
  84.     pathnm, STRLEN(pathnm), offsetof(struct headers, h_path) };
  85. static CONST struct hdrdef subjhdr = {
  86.     subjnm, STRLEN(subjnm), offsetof(struct headers, h_subj) };
  87.  
  88. static CONST struct hdrdef apphdr = {
  89.     appnm, STRLEN(appnm), offsetof(struct headers, h_approved) };
  90. static CONST struct hdrdef ctlhdr = {
  91.     ctlnm, STRLEN(ctlnm), offsetof(struct headers, h_ctlcmd) };
  92. static CONST struct hdrdef exphdr = {
  93.     expnm, STRLEN(expnm), offsetof(struct headers, h_expiry) };
  94. static CONST struct hdrdef distrhdr = {
  95.     distrnm, STRLEN(distrnm), offsetof(struct headers, h_distr) };
  96. static CONST struct hdrdef sendhdr = {
  97.     sendnm, STRLEN(sendnm), offsetof(struct headers, h_sender) };
  98. CONST struct hdrdef xrefhdr = { xrefnm, STRLEN(xrefnm), -1 };
  99.  
  100. static CONST struct hdrdef arthdr = {
  101.     artnm, STRLEN(artnm), offsetof(struct headers, h_artid) };
  102. #endif /* LATTICE_4_0 */
  103.  
  104. static CONST struct hdrdef datrcvhdr = { datercvnm, STRLEN(datercvnm), -1 };
  105. static CONST struct hdrdef rcvhdr = { rcvnm, STRLEN(rcvnm), -1 };
  106. static CONST struct hdrdef psthdr = { postnm, STRLEN(postnm), -1 };
  107. static CONST struct hdrdef pstvrshdr = { postversnm, STRLEN(postversnm), -1 };
  108. static CONST struct hdrdef rlyvrshdr = { rlyversnm, STRLEN(rlyversnm), -1 };
  109. static CONST struct hdrdef illobjhdr = { illobjnm, STRLEN(illobjnm), -1 };
  110.  
  111. /* these are parsed into a struct headers */
  112. CONST struct hdrdef *parsehdrs[] = {
  113.     &msghdr,
  114.     &arthdr,        /* obsolete */
  115.     &ngshdr,
  116.     &pathhdr,        /* modified by hdrmunge.c (emithdr()) */
  117.     &subjhdr,
  118.  
  119.     /* start optional headers */
  120.     &apphdr,
  121.     &ctlhdr,
  122.     &distrhdr,
  123.     &exphdr,
  124.     &sendhdr,
  125.     NULL
  126. };
  127.  
  128. /*
  129.  * the following noxious headers are deleted on contact because neighbours
  130.  * still send them and they are big.  in an ideal world, they wouldn't be
  131.  * sent and thus we wouldn't need to delete them.
  132.  *
  133.  * It is tempting to delete Article-I.D.: too, but it may be too soon
  134.  * for that.
  135.  */
  136. CONST struct hdrdef *hdrvilest[] = {
  137.     &xrefhdr,        /* regenerated by fileart() if needed */
  138.     &datrcvhdr,
  139.     &rcvhdr,
  140.     &psthdr,
  141.     &pstvrshdr,
  142.     &rlyvrshdr,
  143.     &illobjhdr,
  144.     NULL,
  145. };
  146.  
  147. boolean headdebug = NO;
  148.